package com.aferzsoft.colorslide.classes;

import java.util.Random;

import android.graphics.Color;

public class Tile {

	public final static int RED_COLOR_TILE 		= 1;
	public final static int GREEN_COLOR_TILE 	= 2;
	public final static int BLUE_COLOR_TILE 	= 3;
	public final static int CYAN_COLOR_TILE 	= 4;
	public final static int YELLOW_COLOR_TILE 	= 5;
	
	public final static int ON_CREATE_AMOUNT 	= 1;
	
	private int amount;
	private int color;
	
	public Tile(){
		this.amount = ON_CREATE_AMOUNT;
		this.color = getRandomColor();
	}
	
	public Tile( int amount, int color ){
		this.amount = amount;
		this.color = color;
	}
	
	public int getAmount(){
		return this.amount;
	}
	
	public void setAmount( int amount ){
		this.amount = amount;
	}
	
	public int getColor(){
		return this.color;
	}
	
	public void setColor( int color ){
		this.color = color;
	}
	
	public static int getRandomColor(){
	    int randomNum = new Random().nextInt(3) + 1;
	    return getColorByCode( randomNum );
	}
	
	public static int getColorByCode( int code ){
		switch( code ){
	    	case RED_COLOR_TILE:
	    		return Color.rgb( 255, 140, 140 );
	    	case GREEN_COLOR_TILE:
	    		return Color.rgb( 140, 255, 140 );
	    	case BLUE_COLOR_TILE:
	    		return Color.rgb( 140, 140, 255 );
	    	case CYAN_COLOR_TILE:
	    		return Color.rgb( 140, 255, 255 );
	    	case YELLOW_COLOR_TILE:
	    		return Color.rgb( 255, 255, 140 );
		}
		return Color.rgb( 255, 140, 140 );
	}

	@Override
	public String toString(){
		return "Amount: " + this.amount + " - Color: " + this.color; 
	}
}
